package com.bysj.lms.controller;

import com.bysj.lms.common.ResultModel;
import com.bysj.lms.pojo.vo.*;
import com.bysj.lms.service.IStatisticsService;
import com.bysj.lms.utils.LocalDateTimeUtil;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/statistics")
@Api(tags = "综合统计")
public class StatisticsController {

    @Autowired
    IStatisticsService statisticsService;

    @ApiOperation("教师上机课程完成统计")
    @GetMapping("/tcCompletion")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "term",value = "学期",required = true),
            @ApiImplicitParam(name = "tname",value = "教师名")
    })
    public ResultModel courseCompletion(String term,String tname){
        TSSResult tssResult = statisticsService.tcCompletion(term, tname);
        return ResultModel.success("",tssResult);
    }

    @ApiOperation(value = "借用总体统计")
    @GetMapping("/BRStatistics")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startDate",value = "统计开始时间，年月日"),
            @ApiImplicitParam(name = "endDate",value = "统计结束时间，年月日")
    })
    public ResultModel BRStatistics(LocalDate startDate, LocalDate endDate){
        System.out.println(startDate+"====="+endDate);
        BRStatistics brStatistics = statisticsService.brStatistics(startDate, endDate);
        return ResultModel.success("",brStatistics);
    }

    @ApiOperation("各教师借用统计")
    @GetMapping("/TBRStatistics")
    @ApiImplicitParam(name = "uname",value = "教师姓名")
    public ResultModel TBRStatistics(String uid,String uname,LocalDate startDate, LocalDate endDate){
        List<TBRStatistic> tbrStatistics = statisticsService.tbrStatistics(uid, uname, startDate, endDate);
        return ResultModel.success("",tbrStatistics);
    }

    @ApiOperation("各设备借用统计")
    @GetMapping("/SBBRStatistics")
    public ResultModel SBBRStatistics(LocalDate startDate, LocalDate endDate){
        List<SBBRStatistics> sbbrStatistics = statisticsService.sbbrStatistics(startDate, endDate);
        return ResultModel.success("",sbbrStatistics);
    }

    @ApiOperation("设备使用统计")
    @GetMapping("/useStatistics")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name",value = "设备名"),
            @ApiImplicitParam(name = "term",value = "学期，例如2021-2022学年 1学期")
    })
    public ResultModel useStatistics(Integer page,Integer count,String name,String term){
        PageInfo pageInfo = statisticsService.sbUseStatistics(page, count, name, term);
        return ResultModel.success("",pageInfo);
    }

    @ApiOperation("设备维修总体统计")
    @GetMapping("/wxStatistics")
    public ResultModel wxStatistics(String startDate,String endDate){
        WXStatistics wxStatistics = statisticsService.wxStatistics(startDate, endDate);
        return ResultModel.success("",wxStatistics);
    }

    @ApiOperation("各设备维修统计")
    @GetMapping("SBWXStatistics")
    public ResultModel sbwxStatistics(Integer page,Integer count,String startDate,String endDate){
        PageInfo pageInfo = statisticsService.sbwxStatistics(page, count, startDate, endDate);
        return ResultModel.success("",pageInfo);
    }


    @GetMapping("/getModel1")
    public TSSResult getModel(){
        return new TSSResult();
    }

    @GetMapping("/getModel2")
    public TBRStatistic getModel2(){
        return new TBRStatistic();
    }
    @GetMapping("/getModel3")
    public SBBRStatistics getModel3(){
        return new SBBRStatistics();
    }
    @GetMapping("/getModel4")
    public BRStatistics getModel4(){
        return new BRStatistics();
    }

    @GetMapping("/getModel5")
    public WXStatistics getModel5(){
        return new WXStatistics();
    }

    @GetMapping("/getModel6")
    public SBWXStatistics getModel6(){
        return new SBWXStatistics();
    }
}
